package qtdz4;

import javax.swing.*;
import java.awt.*;

public class World extends JPanel {
    public static final int WIDTH = 641;
    public static final int HEIGHT = 479;

    private Battleship ship = new Battleship();
    private SeaObject[] submarine = {new MineSubmarine(),
            new ObserveSubmarine(), new TorpedoSubmarine()};
    private Bomb[] bomb = {new Bomb(100, 200)};
    private Mine[] mine = {new Mine(120, 120)};

    public void paint(Graphics g) {
        Images.sea.paintIcon(null, g, 0, 0);
        ship.paintImage(g);
        for (int i = 0; i < submarine.length; i++) {
            submarine[i].paintImage(g);
        }
        for (int i = 0; i < bomb.length; i++) {
            bomb[i].paintImage(g);
        }
        for (int i = 0; i < mine.length; i++) {
            mine[i].paintImage(g);
        }
    }

    public static void main(String[] args) {
        JFrame frame = new JFrame();
        World world = new World();
        world.setFocusable(true);
        frame.add(world);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(WIDTH + 12, HEIGHT + 39);
        frame.setLocationRelativeTo(null);
        frame.setResizable(false);
        frame.setVisible(true);
    }






    /*
    public static void main(String[] args) {

        SeaObject[] submarine = new SeaObject[6];
        submarine[0]=new MineSubmarine();
        submarine[1]=new MineSubmarine();
        submarine[2]=new ObserveSubmarine();
        submarine[3]=new ObserveSubmarine();
        submarine[4]=new TorpedoSubmarine();
        submarine[5]=new TorpedoSubmarine();
        for(int i=0;i<submarine.length;i++){
            submarine[i].move();
        }
        Mine[] mine = new Mine[3];
        mine[0]=new Mine(100,220);
        mine[1]=new Mine(120,120);
        mine[2]=new Mine(150,150);
        for(int i=0;i<mine.length;i++){
            mine[i].move();
        }
        Bomb[] bomb = new Bomb[3];
        bomb[0]=new Bomb(100,123);
        bomb[1]=new Bomb(150,200);
        bomb[2]=new Bomb(200,250);
        for(int i=0;i<bomb.length;i++){
            bomb[i].move();
        }
    }
     */
}
